package com.sdau.zhang.service.impl;

import com.sdau.zhang.dao.ProductDao;
import com.sdau.zhang.service.IProductService;
import com.sdau.zhang.vo.Product;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class ProductServiceImpl implements IProductService {

    @Autowired
    ProductDao productDao;

    @Override
    @Transactional
    public boolean insertProduct(Product product) {

        int effectNum = productDao.insertProduct(product);
        if(effectNum>0)
            return true;
        else
            return  false;
    }

    @Override
    public List queryAll() {
        return productDao.queryAll();
    }

    @Override
    public String getVegetById(int id) {
        return productDao.getVegetById(id);
    }

    @Override
    public Product queryById(int id) {
        return productDao.queryById(id);
    }

    @Override
    public boolean deal(int pid,int num) {
        Map<String,Integer> map = new HashMap<String, Integer>();
        map.put("pid",pid);
        map.put("num",num);
        int effectNum = productDao.deal(map);

        return false;
    }

    @Override
    public int MaxId() {
        return productDao.MaxId();
    }


}
